#pragma once
#ifndef _UTILS_H
#define _UTILS_H

#include <utility>
#include <ostream>

namespace utils
{

	typedef std::pair<size_t, size_t> coords_t;

	std::ostream& operator<<(std::ostream& os, const coords_t &c)
	{
		os << "[" << c.first << "," << c.second << "]";
		return os;
	}

	template<class T>
	std::ostream& printVector(std::ostream& os, const std::vector<T> &v) {
		os << '[';
		for (size_t i = 0; i < v.size(); i++) {
			os << v[i] << ':';
		}
		os << "]\n";
		return os;
	}

	//x,y - souradnice, n - velikost CTVERCOVE matice
	inline size_t coordsToIndex(const size_t x, const size_t y, const size_t n)
	{
		return y * n + x;
	}

	inline size_t coordsToIndex(const coords_t& _coor, const size_t n)
	{
		return coordsToIndex(_coor.first, _coor.second, n);
	}

	//i - index v 1rozmernem poli, n-velikost ctvercove matice
	coords_t indexToCoords(size_t i, size_t n)
	{
		size_t x, y;
		x = i%n;
		y = i/n;
		return std::pair<size_t,size_t>(x,y);
	}
}

#endif // _UTILS_H
